//package com.demo.minio.config;
//
//import io.minio.MinioClient;
//import io.minio.SetBucketPolicyArgs;
//import io.minio.errors.ErrorResponseException;
//import io.minio.errors.InsufficientDataException;
//import io.minio.errors.InvalidResponseException;
//import io.minio.errors.XmlParserException;
//
//import java.io.IOException;
//import java.security.NoSuchAlgorithmException;
//
///**
// * @author lkz
// * @ClassName: NewSetBucketPolicy
// * @description: minio 8.0之后这是匿名访问权限
// * @date 2022/4/24 16:29
// */
//public class NewSetBucketPolicy {
//
//    public static void main(String[] args)
//            throws IOException, NoSuchAlgorithmException, InvalidKeyException, XmlPullParserException {
//        try {
//            // 新建客户端
//            MinioClient minioClient = new MinioClient("地址", "用户名", "密码");
//
//            try {
//                // 如何获取对应json字符串
//                String config = "  [\n" +
//                        "            {\n" +
//                        "                \"Action\": [\n" +
//                        "                    \"s3:GetBucketLocation\",\n" +
//                        "                    \"s3:ListBucket\"\n" +
//                        "                ],\n" +
//                        "                \"Effect\": \"Allow\",\n" +
//                        "                \"Principal\": \"*\",\n" +
//                        "                \"Resource\": \"arn:aws:s3:::my-bucketname\"\n" +
//                        "            },\n" +
//                        "            {\n" +
//                        "                \"Action\": \"s3:GetObject\",\n" +
//                        "                \"Effect\": \"Allow\",\n" +
//                        "                \"Principal\": \"*\",\n" +
//                        "                \"Resource\": \"arn:aws:s3:::my-bucketname/myobject*\"\n" +
//                        "            }\n" +
//                        "        ],\n" +
//                        "        \"Version\": \"2012-10-17\"\n" +
//                        "    }";
//                this.minioClient.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(bucketName).config(config).build());
//
//            } catch (ErrorResponseException | InsufficientDataException
//                    | InternalException | InvalidKeyException
//                    | InvalidResponseException | IOException
//                    | NoSuchAlgorithmException | ServerException
//                    | XmlParserException e) {
//                log.error("[seed] [minio] 设置桶:{}策略失败", bucketName, e);
//            }
//        }
//
//    }
